#pragma once

#include <compl.h> 


/* 泛型 flatmap */
#define DEF_FLATMAP(datatype, name, totalnr, oalloc, ofree)	\
static datatype *flatmap_##name ;  \
static inline datatype *flatmap_create_##name(){	\
	void *mem = oalloc(sizeof(datatype) * totalnr);\
	flatmap_##name = (datatype *)mem;\
	return flatmap_##name;\
}\
static inline void flatmap_destroy_##name(){\
	ofree(flatmap_##name , sizeof(datatype) * totalnr);\
	flatmap_##name = NULL;\
}\
SAI datatype flatmap_get_##name(word_t idx){\
	return atm_ld(&flatmap_##name[idx]);\
}\
SAI void flatmap_set_##name(word_t idx, datatype val){\
	atm_st(&flatmap_##name[idx], val);\
}

